﻿Public Class FormGTGBMHJC
    Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    Public usr As String
    Public mes_project_name As String = String.Empty
    Dim txt As TextBox
    Dim objMstTechnology As New clsMstTechnology
    Dim objGjbMst As New clsGjbMst
    Dim objGTGBMHJC As New clsGTGBMHJC
    Dim update_status As String = "INSERT_TYPE"
    Dim en As entityGTGBMHJC
    Dim _sys_id As String

    Public Property Sys_id As String
        Get
            Return _sys_id
        End Get
        Set(value As String)
            _sys_id = value
        End Set
    End Property
    Private Sub FormGTGBMHJC_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = GetIniFile("JS", "JS2", "", g_jsInitFileName)
        txtDate.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True
        txtDate.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True
        initForm()
        If _sys_id <> "" Then
            update_status = "UPDATE_TYPE"
            setContentBySysid()
        Else
            update_status = "INSERT_TYPE"
        End If
    End Sub

    Private Sub initForm()
        Dim dtMstTechnology As DataTable = objMstTechnology.getListByName(Me.Text)
        If dtMstTechnology.Rows.Count > 0 Then
            txtId.Text = dtMstTechnology.Rows(0)("sys_id").ToString()
            txtRequirement.Text = dtMstTechnology.Rows(0)("requirement").ToString()
        End If
        Dim dtGjbMst As DataTable = objGjbMst.selectAll(String.Empty)
        cmb_gjb_type.ValueMember = "mst_value"
        cmb_gjb_type.DisplayMember = "mst_value_name"
        cmb_gjb_type.DataSource = dtGjbMst
        If dtGjbMst.Rows.Count > 0 Then
            cmb_gjb_type.SelectedIndex = 0
        End If
        Dim TDate As String = Now.ToString()
        txtDate.Text = TDate
        txt_project_name.Text = String.Empty
        txt_primer_max_1.Value = 0
        txt_primer_min_1.Value = 0
        txt_primer_avg_1.Value = 0
        txt_primer_s_1.Value = 0
        txt_primer_max_2.Value = 0
        txt_primer_min_2.Value = 0
        txt_primer_avg_2.Value = 0
        txt_primer_s_2.Value = 0
        txt_face_glue_max_1.Value = 0
        txt_face_glue_min_1.Value = 0
        txt_face_glue_avg_1.Value = 0
        txt_face_glue_s_1.Value = 0
        txt_face_glue_max_2.Value = 0
        txt_face_glue_min_2.Value = 0
        txt_face_glue_avg_2.Value = 0
        txt_face_glue_s_2.Value = 0
        txt_face_glue_max_3.Value = 0
        txt_face_glue_min_3.Value = 0
        txt_face_glue_avg_3.Value = 0
        txt_face_glue_s_3.Value = 0
        txt_face_glue_max_4.Value = 0
        txt_face_glue_min_4.Value = 0
        txt_face_glue_avg_4.Value = 0
        txt_face_glue_s_4.Value = 0
    End Sub

    Public Sub setTxtProjectName()
        txt_project_name.Text = mes_project_name
    End Sub

    Private Sub setContentBySysid()
        Dim dt As DataTable = objGTGBMHJC.selectBySysid(_sys_id)
        If dt.Rows.Count > 0 Then
            Dim row As DataRow = dt.Rows(0)
            txtRequirement.Text = row("requirement")
            txtId.Text = row("technology_id")
            txtDate.Text = row("oper_date")
            txt_project_name.Text = row("mes_project_name")
            cmb_gjb_type.Text = row("gjb_type")
            txt_primer_max_1.Text = row("primer_max_1")
            txt_primer_min_1.Text = row("primer_min_1")
            txt_primer_avg_1.Text = row("primer_avg_1")
            txt_primer_s_1.Text = row("primer_s_1")
            txt_primer_max_2.Text = row("primer_max_2")
            txt_primer_min_2.Text = row("primer_min_2")
            txt_primer_avg_2.Text = row("primer_avg_2")
            txt_primer_s_2.Text = row("primer_s_2")
            txt_face_glue_max_1.Text = row("face_glue_max_1")
            txt_face_glue_min_1.Text = row("face_glue_min_1")
            txt_face_glue_avg_1.Text = row("face_glue_avg_1")
            txt_face_glue_s_1.Text = row("face_glue_s_1")
            txt_face_glue_max_2.Text = row("face_glue_max_2")
            txt_face_glue_min_2.Text = row("face_glue_min_2")
            txt_face_glue_avg_2.Text = row("face_glue_avg_2")
            txt_face_glue_s_2.Text = row("face_glue_s_2")
            txt_face_glue_max_3.Text = row("face_glue_max_3")
            txt_face_glue_min_3.Text = row("face_glue_min_3")
            txt_face_glue_avg_3.Text = row("face_glue_avg_3")
            txt_face_glue_s_3.Text = row("face_glue_s_3")
            txt_face_glue_max_4.Text = row("face_glue_max_4")
            txt_face_glue_min_4.Text = row("face_glue_min_4")
            txt_face_glue_avg_4.Text = row("face_glue_avg_4")
            txt_face_glue_s_4.Text = row("face_glue_s_4")
        End If
    End Sub

    Private Sub txt_num_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_primer_max_1.MouseDown,
        txt_primer_s_2.MouseDown, txt_primer_s_1.MouseDown, txt_primer_min_2.MouseDown,
        txt_primer_min_1.MouseDown,
        txt_primer_max_2.MouseDown, txt_primer_avg_2.MouseDown, txt_primer_avg_1.MouseDown,
        txt_face_glue_s_4.MouseDown, txt_face_glue_s_3.MouseDown, txt_face_glue_s_2.MouseDown,
        txt_face_glue_s_1.MouseDown, txt_face_glue_min_4.MouseDown, txt_face_glue_min_3.MouseDown,
        txt_face_glue_min_2.MouseDown, txt_face_glue_min_1.MouseDown, txt_face_glue_max_4.MouseDown,
        txt_face_glue_max_3.MouseDown, txt_face_glue_max_2.MouseDown, txt_face_glue_max_1.MouseDown,
        txt_face_glue_avg_4.MouseDown, txt_face_glue_avg_3.MouseDown, txt_face_glue_avg_2.MouseDown,
        txt_face_glue_avg_1.MouseDown
        UcDigitalKeyboard1 = New ucDigitalKeyboard
        If sender.MaskBox.Mask.EditMask = "d" Then
            UcDigitalKeyboard1.B_01 = False
        Else
            UcDigitalKeyboard1.B_01 = True
        End If

        If sender.GetType().Name.Equals("TextEdit") Then
            UcDigitalKeyboard1.B_02 = True
        Else
            UcDigitalKeyboard1.B_02 = False
        End If

        UcDigitalKeyboard1.Txt = sender

        Me.Controls.Add(UcDigitalKeyboard1)
        UcDigitalKeyboard1.Show()
        UcDigitalKeyboard1.BringToFront()
        UcDigitalKeyboard1.Focus()
    End Sub

    Private Sub setEntity()
        en = New entityGTGBMHJC
        With en
            .sys_id = _sys_id
            .factory_id = "TS"
            .technology_id = txtId.Text
            .oper_date = txtDate.Text
            .mes_project_name = txt_project_name.Text.Trim()
            .gjb_type = cmb_gjb_type.Text.Trim()
            .primer_max_1 = txt_primer_max_1.Text
            .primer_min_1 = txt_primer_min_1.Text
            .primer_avg_1 = txt_primer_avg_1.Text
            .primer_s_1 = txt_primer_s_1.Text
            .primer_max_2 = txt_primer_max_2.Text
            .primer_min_2 = txt_primer_min_2.Text
            .primer_avg_2 = txt_primer_avg_2.Text
            .primer_s_2 = txt_primer_s_2.Text
            .face_glue_max_1 = txt_face_glue_max_1.Text
            .face_glue_min_1 = txt_face_glue_min_1.Text
            .face_glue_avg_1 = txt_face_glue_avg_1.Text
            .face_glue_s_1 = txt_face_glue_s_1.Text
            .face_glue_max_2 = txt_face_glue_max_2.Text
            .face_glue_min_2 = txt_face_glue_min_2.Text
            .face_glue_avg_2 = txt_face_glue_avg_2.Text
            .face_glue_s_2 = txt_face_glue_s_2.Text
            .face_glue_max_3 = txt_face_glue_max_3.Text
            .face_glue_min_3 = txt_face_glue_min_3.Text
            .face_glue_avg_3 = txt_face_glue_avg_3.Text
            .face_glue_s_3 = txt_face_glue_s_3.Text
            .face_glue_max_4 = txt_face_glue_max_4.Text
            .face_glue_min_4 = txt_face_glue_min_4.Text
            .face_glue_avg_4 = txt_face_glue_avg_4.Text
            .face_glue_s_4 = txt_face_glue_s_4.Text
            .oper = usr
        End With
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If String.IsNullOrEmpty(txt_project_name.Text.Trim()) Then
            MsgBox("请输入项目名称", vbYes, "提示")
            Exit Sub
        End If
        If String.IsNullOrEmpty(txtDate.Text.Trim()) Then
            MsgBox("请选择操作日期", vbYes, "提示")
            Exit Sub
        End If
        setEntity()
        If update_status = "INSERT_TYPE" Then
            If objGTGBMHJC.insert(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                initForm()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
        If update_status = "UPDATE_TYPE" Then
            If objGTGBMHJC.update(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                CType(Owner, FormGTGBMHJCRecord).setDgvData()
                Close()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
    End Sub

    Private Sub btnTiQuFromMesPlan_Click(sender As Object, e As EventArgs) Handles btnTiQuFromMesPlan.Click
        Dim formMesPlan As New FormMesPlan()
        formMesPlan.usr = usr
        formMesPlan.btnShow = True
        formMesPlan.originForm = "FormGTGBMHJC"
        formMesPlan.ShowDialog(Me)
    End Sub

End Class

Public Class entityGTGBMHJC
    Public sys_id As String
    Public factory_id As String
    Public technology_id As String '工艺ID
    Public oper_date As String '日期时间
    Public mes_project_name As String '项目名称
    Public gjb_type As String '规格型号
    Public primer_max_1 As String '底胶1最大值
    Public primer_min_1 As String '底胶1最小值
    Public primer_avg_1 As String '底胶1均值
    Public primer_s_1 As String '底胶1S
    Public primer_max_2 As String '底胶2最大值
    Public primer_min_2 As String '底胶2最小值
    Public primer_avg_2 As String '底胶2均值
    Public primer_s_2 As String '底胶2S
    Public face_glue_max_1 As String '面胶1最大值
    Public face_glue_min_1 As String '面胶1最小值
    Public face_glue_avg_1 As String '面胶1平均值
    Public face_glue_s_1 As String '面胶1S
    Public face_glue_max_2 As String '面胶2最大值
    Public face_glue_min_2 As String '面胶2最小值
    Public face_glue_avg_2 As String '面胶2平均值
    Public face_glue_s_2 As String '面胶2S
    Public face_glue_max_3 As String '面胶3最大值
    Public face_glue_min_3 As String '面胶3最小值
    Public face_glue_avg_3 As String '面胶3平均值
    Public face_glue_s_3 As String '面胶3S
    Public face_glue_max_4 As String '面胶4最大值
    Public face_glue_min_4 As String '面胶4最小值
    Public face_glue_avg_4 As String '面胶4平均值
    Public face_glue_s_4 As String '面胶4S
    Public oper As String '操作人
End Class